package com.le.tester.javaThink.fourth.concurrency;

import java.util.concurrent.TimeUnit;

/**
 * createTime：2021/9/13 16:18
 * description：不执行finally就终止了run
 */

class ADaemon implements Runnable {

    @Override
    public void run() {
        try {
            System.out.println("starting aDaemon");
            TimeUnit.SECONDS.sleep(1);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        } finally {
            System.out.println("this should always run?");
        }
    }
}

public class DaemonsDontRunFinally {
    public static void main(String[] args) {
        Thread thread = new Thread(new ADaemon());
        thread.setDaemon(true);
        thread.start();
    }
}
